import { Message } from '@arco-design/web-vue';

export const sleep = (time: number) => {
  return new Promise((resolve) => {
    setTimeout(() => {
      resolve(true);
    }, time);
  });
};
export const downFileToExcel = (name: string, res: any) => {
  if (res?.type === 'application/json') {
    const response = new Response(res);
    response.json().then((data) => {
      Message.error(data.message); // 这里的data就是一个解析后的对象
    });
    return;
  }
  const elink = document.createElement('a');
  elink.download = name;
  elink.style.display = 'none';
  const blob = new Blob([res], { type: 'application/vnd.ms-excel' });
  elink.href = URL.createObjectURL(blob);
  document.body.appendChild(elink);
  elink.click();
  document.body.removeChild(elink);
};
export const name = 'uncle';
